Prev Next |
Sitecore XML format subjected to XSL transformations became lighter in Sitecore V5 allowing faster transformations. To illustrate the difference, we will take a simple Sitecore Item and compare Sitecore V4 XML to Sitecore V5 XML. Please note that this format differs from the one used to serialize an entire Item.
1. Code Sample 1: Sitecore V4 Item XML
1 <item name="Home" key="home" template="document" sortorder="10" action="edit" revision="1.0" created="20021129T211448" createdby="Admin" updated="20060213T151606" updatedby="Admin" layout="{guid}" renderings="{guid}|" id="{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" parentid="{guid}" tid="{guid}">
2 <xsecurity />
3 <field name="Title" key="title" nolang="0" sortorder="10" type="text">
4 <content lang="en">Welcome</content>
5 <content lang="da">Velkommen til SiteCore</content>
6 </field>
7 <field name="Text" key="text" nolang="0" sortorder="20" type="html">
8 - <content lang="en">
9 <P>Welcome to SiteCore</P>
10 </content>
11 <content lang="da">Dette er SiteCore</content>
12 </field>
13 </item>
2. Code Sample 2: Sitecore V5 Item XML
<item name="Home" key="home" id="{guid}" tid="{guid}" mid="{guid}" sortorder="10" language="en" version="1" template="document" parentid="{guid}">
<fields>
..
<field tfid="{guid}" key="text" type="html" />
<field tfid="{guid}" key="title" type="text" />
</fields>
</item>
You can use <xsl:copy-of select=”$sc_item” /> to see exactly how your Item looks like in XML. Refer to the Display Raw XML article on SDN5 for more details.
The sections below will guide you through the breaking changes in the new XML format and provide recommendations on porting the existing XSL transformations to the new format.
Supplementary reading:
- Understanding the Sitecore XML SDN5 article.
3. Missing Attributes
In Sitecore V5, an <item> element has less attributes defined. The reason is that some of the attributes became first-class fields of their own.
The missing attributes are
Sitecore V4 attribute |
Sitecore V5 analogue |
@created | ‘__created’ field |
@createdBy | ‘__created by’ field |
@updated | ‘__updated’ field |
@updatedBy | ‘__updated by’ field |
@layout | ‘__renderings’ field |
@renderings | ‘__renderings’ field
Note that __renderings field contains both layout and rendering data for all devices. It also has a different internal format |
@revision | ‘__revision’ field. Revision is GUID in Sitecore V5 |
@action | Sitecore state API. |
If your transformations depend on any of the attributes above, you will need to update them accordingly. In most cases you will need to replace direct attribute access to a built-in field access method:
Sitecore V4:
<xsl:value-of select=”@created” /> Sitecore V5: <xsl:value-of select=”{sc:fld(‘__created’, .)}” />
4. Field Values
Field values are not included in V5 XML format; all fields appear to be empty. To get the value of a field, you should use the sc:fld xsl extension method.
As long as using the sc:fld method was considered a best practice in Sitecore V4, the change will not affect most xsl transformations.
Sitecore V4: ./field[@key=’text’]/content (bad practice)
Sitecore V5: sc:fld(‘text’, .)
5. Concepts Introduced in Sitecore V5
Because of the new concepts introduced in Sitecore V5, some XSL logic might be indirectly affected.
More useful information on the subject is available here:
Prev Next